namespace Console;

/// <summary>
/// 学生类
/// </summary>
public class Student{

    #region 构造函数

    // 构造方法
    public Student() {
        
    }

    public Student(string name,string sex,int score,int money) {
        _name = name;
        _sex = sex;
        _score = score;
        _money = money;
    }

    #endregion
    
    #region 字段

    // 字段
    private string _name;
    private string _sex;
    private int _score;
    private int _money;

    #endregion

    #region 属性

    // 属性
    public string Name {
        get { return _name; }
        set { _name = value; }
    }

    public string Sex {
        get { return _sex; }
        set {_sex = value; }
    }

    public int Score {
        set { _score = value; }
    }

    public string Level {
        get {
            // 模式匹配
            string level = _score switch {
                <60 => "差",
                <70 and >=60 => "一般",
                <80 and >=70 => "良",
                _ => "优" // 弃元模式，相当于defaul
            };
            
            return level;
        }
    }

    public int Money {
        get { return _money; }
        set { _money = value; }
    }

    #endregion

    #region 方法

    public void Print() {
        System.Console.WriteLine($"姓名:{_name},性别：{_sex}，成绩:{_score}，零花钱:{_money}");
    }

    /// <summary>
    /// 帮其他同学购物
    /// </summary>
    /// <param name="student">被帮助的同学</param>
    /// <param name="money">购物所化的金额</param>
    public void HelpShop(Student s, int money) {
        s._money -= (money+1);
        this._money++;
    }
    #endregion
    
}